﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

using System.IO;
using System.Net;

namespace Chapter26.BasicWebClient
{
    /// <summary>
    /// WebProxyWindow.xaml 的交互逻辑
    /// </summary>
    public partial class WebProxyWindow : Window
    {
        public WebProxyWindow()
        {
            InitializeComponent();

            GetResponse();
        }

        private void GetResponse()
        {
            var webProxy = new WebProxy("192.168.1.100", true);
            webProxy.Credentials = new NetworkCredential("user1", "user1Password");
            var webRequest = WebRequest.Create("http://hao.360.com");
            webRequest.Proxy = webProxy;
            var webResponse = webRequest.GetResponseAsync();
        }

        private void GetResponse2()
        {
            var webProxy = new WebProxy("192.168.1.100", true);
            webProxy.Credentials = new NetworkCredential("user1", "user1Password", "myDomain");
            var webRequest = WebRequest.Create("http://hao.360.com");
            webRequest.Proxy = webProxy;
            var webResponse = webRequest.GetResponseAsync();
        }
    }
}
